package www.huiting.user.controller;

import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import www.huiting.user.service.GreeterRequest;
import www.huiting.user.service.IUserApiService;
import www.huiting.user.service.IUserService;

import java.util.List;


@RestController
@RequestMapping("user")
public class UserController {
   @Resource
    private IUserService userService;
    @GetMapping("info1")
    public Mono<List<String>> getInfo1(){

        return  userService.getList();
    }
    @GetMapping("info2")
    public Mono<String> getInfo2(){

        return  userService.getUserById(Mono.just(GreeterRequest.newBuilder().build()))
                .map(v->v.getMessage()).onErrorResume(e->
                        Mono.just("error"+e.toString())
                );
    }
}
